package com.system.controller.question;

import com.common.core.controller.BaseController;
import com.common.core.domain.Result;
import com.common.core.domain.TableDataInfo;
import com.system.domain.question.dto.QuestionAddDTO;
import com.system.domain.question.dto.QuestionEditDTO;
import com.system.domain.question.dto.QuestionQueryDTO;
import com.system.domain.question.vo.QuestionDetailVO;
import com.system.service.question.QuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/question")
@Tag(name = "题目管理API")
public class QuestionController extends BaseController {
    @Resource
    QuestionService questionService;

    /**
     * 根据当前的筛选条件来获取题目列表
     *
     */
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return getTableData(questionService.list(questionQueryDTO));
    }

    /**
     * 添加题目
     *
     */
    @PostMapping("/add")
    public Result<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toResult(questionService.add(questionAddDTO));
    }

    /**
     * 获取题目详情
     *
     */
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        return Result.success(questionService.detail(questionId));
    }

    /**
     * 编辑更新题目
     *
     */
    @PutMapping("/edit")
    public Result<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toResult(questionService.edit(questionEditDTO));
    }

    /**
     *删除题目
     *
     */
    @DeleteMapping("/delete")
    public Result<Void> delete(Long questionId){
        return toResult(questionService.delete(questionId));
    }
}
